package com.itheima.d8_thread_pool;

import java.util.concurrent.*;

/*
    目标：掌握线程池的创建。
    需求 : 使用线程池处理Runnable类型任务
 */
public class ThreadPoolTest2 {
    public static void main(String[] args) {
        // 创建线程池
        final ThreadPoolExecutor tp = new ThreadPoolExecutor(
                10,
                10,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(4),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );

        for (int i = 0; i < 10; i++) {
            tp.execute(new MyRunnable());
        }

    }
}
